package com.dindang.checkline.mvp.model;

import android.app.Application;

import com.dindang.checkline.mvp.model.api.service.CommonService;
import com.dindang.checkline.mvp.model.entity.BaseResponse;
import com.dindang.checkline.mvp.model.entity.TaskDetail;
import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import com.jess.arms.di.scope.ActivityScope;

import javax.inject.Inject;

import com.dindang.checkline.mvp.contract.TaskDetailContract;
import com.longxi.gamer_base.BaseAppConst;

import java.util.List;

import io.reactivex.Observable;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 03/05/2019 16:39
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
@ActivityScope
public class TaskDetailModel extends BaseModel implements TaskDetailContract.Model {
    @Inject
    Gson mGson;
    @Inject
    Application mApplication;

    @Inject
    public TaskDetailModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<BaseResponse<TaskDetail>> quertTaskDetail(TaskDetail.TaskDetailParam param) {
        Observable<BaseResponse<TaskDetail>> base = mRepositoryManager.obtainRetrofitService(CommonService.class)
                .quertTaskDetail(
                        param.id
                );
        return base;
    }

    @Override
    public Observable<BaseResponse> changeStatus(TaskDetail.ChangeStatus param) {
        Observable<BaseResponse> base = mRepositoryManager.obtainRetrofitService(CommonService.class)
                .changeStatus(param.id, BaseAppConst.accountInfo.getUserId()+""
                );
        return base;
    }
}